{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## ROC 曲线"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn import datasets\n",
    "\n",
    "digits = datasets.load_digits()\n",
    "X = digits.data\n",
    "y = digits.target.copy()\n",
    "\n",
    "y[digits.target==9] = 1\n",
    "y[digits.target!=9] = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=666)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LogisticRegression\n",
    "\n",
    "log_reg = LogisticRegression()\n",
    "log_reg.fit(X_train, y_train)\n",
    "decision_scores = log_reg.decision_function(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from playML.metrics import FPR, TPR\n",
    "\n",
    "fprs = []\n",
    "tprs = []\n",
    "thresholds = np.arange(np.min(decision_scores), np.max(decision_scores), 0.1)\n",
    "for threshold in thresholds:\n",
    "    y_predict = np.array(decision_scores >= threshold, dtype='int')\n",
    "    fprs.append(FPR(y_test, y_predict))\n",
    "    tprs.append(TPR(y_test, y_predict))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAECZJREFUe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ufSdJxzRCwGbgPem5kPN5CxblXmfG5EROvxG4BjgV7+T63jnDNz\naWYuycwlwFeBD2dmrUezU6jKPp7fto8vYbSPa9vHlW7524ScgfeRrzLniJgPbAVOBg5HxB8z+i78\ngcaCT0LF/fwJ4HRGj+QARrKHbzRVcc6/y+iBy4vA88Dvt73B2nMqzrkYFed7FfBHETHC6D5eW+c+\n9hOqklSg6XxaRpI0QZa7JBXIcpekAlnuklQgy12SCmS5S1KBLHdJKpDlLkkF+j9jI3cd3SpnBQAA\nAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11a59b588>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(fprs, tprs)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### scikit-learn中的ROC"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.metrics import roc_curve\n",
    "\n",
    "fprs, tprs, thresholds = roc_curve(y_test, decision_scores)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADotJREFUeJzt3W+IXXedx/H3ZxMLitaqGaUmzSa7xD8ja4uOjbuU3bqy\na1KQIPigrVgsSrZsKz5s2Qf2gU8Ud0HFagglW2SpWViLzS7RurBoF2qzTZfYNi2V2RTTxEKnrSjo\ngzL0uw/m1r07nck9M7lz79zffb9g4J5zfrnn+2PCJ7/8zu+ck6pCktSWPxh3AZKk4TPcJalBhrsk\nNchwl6QGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ3aOq4Tb9u2rXbt2jWu00vSRHr00UdfqKqZQe3G\nFu67du3i5MmT4zq9JE2kJL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u4C1Jfpzk0SQ3jay6jdGlz98E\n3gv8Engc+EJVvTKa8sZiQ/Nr4l6QrSVJPsJSuF8z7lpG4GvA7VX1ytKgbipsBT4IfBR4PfDTJA9X\n1c/HW9aG+hhwCvhL4I+Bf0/yn1X1m/GWNZk2c7hP43PkO/UnyfuBu4H9VfXiiGrbKF36PAcc7QX7\nNuC6JItV9f3RlDh0Xfp8Dnixqn4L/DbJg8CVwKSGe5c+3wx8uZYmpOeTPAO8B/iv0ZQ4chuaX5t5\nWmYanyM/sM9JdgL3AZ9uZBQ3sM9VtbuqdlXVLuBfgL+d4GCHbn+37weuSbI1yRuAvcBTI65zmLr0\n+SxL/1MhyTuAdwNnRlrlaG1ofm3akXtN4XPkO/b5i8DbgG/1RrKLNcEPXerY56Z06XNVPZXkh8Bj\nwCvA3VW14pK6SdDx9/wl4J4kj7O0guT2qprYp0Um+S5wLbAtyTngTuB1MJr88g5VSWrQZp6WkSSt\nk+EuSQ0y3CWpQYa7JDXIcJekBhnuktQgw12SGmS4S1KD/hektxxcMN0dlwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11a6b86a0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(fprs, tprs)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### ROC AUC"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.98304526748971188"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.metrics import roc_auc_score\n",
    "\n",
    "roc_auc_score(y_test, decision_scores)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
